﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display.ValentineUI {
    import flash.events.*;
    import Engine.Managers.*;
    import flash.utils.*;
    import Display.DialogUI.*;
    import org.aswing.*;
    import Classes.*;
    import Classes.sim.*;
    import org.aswing.geom.*;
    import Display.*;
    import flash.text.*;
    import Display.aswingui.*;
    import Modules.stats.types.*;

    public class AdmirersPanel extends JPanel {

        public static const ADMIRERS_PER_PAGE:Number = 15;

        private var m_headerPanel:JPanel;
        private var m_portraitsPanel:JPanel;
        private var m_portraitsShelf:JPanel;
        private var m_footerPanel:JPanel;
        private var m_assetDict:Dictionary;
        private var m_admirers:Array;

        public function AdmirersPanel(){
            super(new SoftBoxLayout(SoftBoxLayout.Y_AXIS, 0, SoftBoxLayout.TOP));
            this.m_admirers = ValentineManager.getAdmirers();
            while ((this.m_admirers.length % ADMIRERS_PER_PAGE) != 0) {
                this.m_admirers.push(new Admirer(null, null, 0, false));
            };
            this.init();
        }
        protected function init():void{
            ASwingHelper.setEasyBorder(this, 0, 20);
            this.m_headerPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            this.m_portraitsPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            this.m_footerPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.CENTER);
            this.append(ASwingHelper.verticalStrut(8));
            this.append(this.makeHeaderPanel());
            this.append(this.makePortraitsPanel());
            this.append(this.makeFooterPanel());
            ASwingHelper.prepare(this);
            dispatchEvent(new Event(MakerPanel.PREPARE, true));
        }
        protected function makeHeaderPanel():JPanel{
            var _local1:String = ZLoc.t("Dialogs", "ValUI_admirer_header");
            var _local2:AssetPane = ASwingHelper.makeMultilineText(_local1, 700, EmbeddedArt.DEFAULT_FONT_NAME_BOLD, TextFormatAlign.CENTER, 16, EmbeddedArt.brownTextColor);
            this.m_headerPanel.append(_local2);
            return (this.m_headerPanel);
        }
        protected function makePortraitsPanel():JPanel{
            this.m_portraitsShelf = new AdmirersScrollingList(this.m_admirers, AdmirersCellFactory, 0, 5, 3, ADMIRERS_PER_PAGE);
            ASwingHelper.prepare(this.m_portraitsShelf);
            this.m_portraitsPanel.append(this.m_portraitsShelf);
            return (this.m_portraitsPanel);
        }
        protected function makeFooterPanel():JPanel{
            var _local1:String = ZLoc.t("Dialogs", "ValUI_admirer_footer", {
                numAdmirers:ValentineManager.getTotalAdmirers(),
                numCards:ValentineManager.getTotalCards()
            });
            var _local2:AssetPane = ASwingHelper.makeMultilineText(_local1, 700, EmbeddedArt.DEFAULT_FONT_NAME_BOLD, TextFormatAlign.CENTER, 16, EmbeddedArt.blueTextColor);
            this.m_footerPanel.append(_local2);
            _local1 = ZLoc.t("Dialogs", "Share");
            var _local3:JPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.CENTER);
            var _local4:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            var _local5:CustomButton = new CustomButton(_local1, null, "PinkButtonUI");
            _local5.setFont(ASwingHelper.makeFont(EmbeddedArt.TITLE_FONT, 18));
            _local5.setPreferredSize(new IntDimension(190, 30));
            _local5.setMinimumSize(new IntDimension(190, 30));
            _local5.setMaximumSize(new IntDimension(190, 30));
            _local4.appendAll(ASwingHelper.horizontalStrut(5), _local5, ASwingHelper.horizontalStrut(5));
            _local3.appendAll(ASwingHelper.verticalStrut(5), _local4, ASwingHelper.verticalStrut(5));
            _local5.addEventListener(MouseEvent.CLICK, this.onButtonClick, false, 0, true);
            this.m_footerPanel.append(_local3);
            this.m_footerPanel.append(ASwingHelper.verticalStrut(20));
            return (this.m_footerPanel);
        }
        protected function onButtonClick(_arg1:MouseEvent):void{
            if (!Global.world.viralMgr.vdayBragAboutAdmirers()){
                UI.displayMessage(ZLoc.t("Dialogs", "ValUI_throttle"), GenericDialogView.TYPE_OK);
            };
            StatsManager.count(StatsCounterType.CARDMAKER, StatsKingdomType.VDAY_2011, StatsPhylumType.ADMIRERS, "share");
        }

    }
}//package Display.ValentineUI 
